package com.hengxinguotong.zhihuichengjian.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.hengxinguotong.zhihuichengjian.R;
import com.hengxinguotong.zhihuichengjian.bean.WorkHoursDetail;
import com.hengxinguotong.zhihuichengjian.treeview.RecyclerAdapter;
import com.hengxinguotong.zhihuichengjian.widget.font.HXTextView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @CopyRight 恒信国通信息科技
 * @Author WuLei
 * @Date 2019/4/4
 * <p>
 * 工时明细详情
 */

public class WorkHoursDetailAdapter extends RecyclerAdapter<WorkHoursDetail, WorkHoursDetailAdapter.WorkHoursDetailViewHolder> {

    public WorkHoursDetailAdapter(Context context, List<WorkHoursDetail> dataList) {
        super(context, dataList);
    }

    @Override
    public WorkHoursDetailViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.item_attendance_work_time_detail, null);
        return new WorkHoursDetailViewHolder(view);
    }

    @Override
    public void onBindViewHolder(WorkHoursDetailViewHolder holder, int position) {
        holder.bindData(position);
    }

    public class WorkHoursDetailViewHolder extends RecyclerAdapter.BaseViewHolder<WorkHoursDetail> {
        @BindView(R.id.person_name)
        HXTextView personName;
        @BindView(R.id.work_time)
        HXTextView workTime;
        @BindView(R.id.enter_time_tv)
        HXTextView enterTimeTv;
        @BindView(R.id.exit_time_tv)
        HXTextView exitTimeTv;

        public WorkHoursDetailViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void bindData(int position) {
            WorkHoursDetail workHoursDetail = dataList.get(position);
            personName.setText(workHoursDetail.getPersonName());
            workTime.setText("日总工时：" + workHoursDetail.getTime() + "小时");
            enterTimeTv.setText(workHoursDetail.getDate() + " " + workHoursDetail.getUpTime());
            exitTimeTv.setText(workHoursDetail.getDate() + " " + workHoursDetail.getDownTime());
        }
    }
}
